package com.review.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.review.project.domain.ProjectData;
import com.review.project.service.IProjectDataService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.review.common.annotation.Log;
import com.review.common.core.controller.BaseController;
import com.review.common.core.domain.AjaxResult;
import com.review.common.enums.BusinessType;
import com.review.common.utils.poi.ExcelUtil;
import com.review.common.core.page.TableDataInfo;

/**
 * 项目数据Controller
 * 
 * @author Evan
 * @date 2022-03-15
 */
@RestController
@RequestMapping("/project/projectData")
public class ProjectDataController extends BaseController
{
    @Autowired
    private IProjectDataService projectDataService;

    /**
     * 查询项目数据列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectData projectData)
    {
        startPage();
        List<ProjectData> list = projectDataService.selectProjectDataList(projectData);
        return getDataTable(list);
    }

    /**
     * 导出项目数据列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:export')")
    @Log(title = "项目数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectData projectData)
    {
        List<ProjectData> list = projectDataService.selectProjectDataList(projectData);
        ExcelUtil<ProjectData> util = new ExcelUtil<ProjectData>(ProjectData.class);
        util.exportExcel(response, list, "项目数据数据");
    }

    /**
     * 获取项目数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(projectDataService.selectProjectDataById(id));
    }

    /**
     * 新增项目数据
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:add')")
    @Log(title = "项目数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectData projectData)
    {
        return toAjax(projectDataService.insertProjectData(projectData));
    }

    /**
     * 修改项目数据
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:edit')")
    @Log(title = "项目数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectData projectData)
    {
        return toAjax(projectDataService.updateProjectData(projectData));
    }

    /**
     * 删除项目数据
     */
    @PreAuthorize("@ss.hasPermi('project:projectData:remove')")
    @Log(title = "项目数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectDataService.deleteProjectDataByIds(ids));
    }
}
